package net.maku.module.train.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import net.maku.framework.common.utils.PageResult;
import net.maku.framework.common.utils.Result;
import net.maku.module.train.convert.CourseConvert;
import net.maku.module.train.entity.CourseEntity;
import net.maku.module.train.service.CourseService;
import net.maku.module.train.vo.CourseVO;
import net.maku.newbase.NewBaseController;
import net.maku.newbase.NewQuery;
import net.maku.newbase.PageParam;

import org.springframework.web.bind.annotation.*;

/**
* 业务_课程
*
* @author    
*/
@RestController
@RequestMapping("nb/course")
@Tag(name="业务_课程")
@AllArgsConstructor
public class CourseController extends NewBaseController<CourseService, CourseEntity> {

    @GetMapping("page")
    @Operation(summary = "分页")
    public Result<PageResult<CourseVO>> page(PageParam page, NewQuery query){
        LambdaQueryWrapper<CourseEntity> select = new LambdaQueryWrapper<>();

        IPage<CourseEntity> iPage = entityService.page(page.b(), select);
        return Result.ok(new PageResult<>(CourseConvert.INSTANCE.convertList(iPage.getRecords()), iPage.getTotal()));
    }

}